package org.example.demo03.ioc;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/prop")
@RestController
public class PropertiesController {
    @Value("${my.key}")
    private String myKey;

    @Value("${my.key2}")
    private String myKey2;

    private String myKey3;

    @RequestMapping("/readValue")
    public String readValue() {
        return "从配置文件中读取配置信息：" + myKey;
    }

    @PostConstruct
    public void readValue2() {
        System.out.println("从配置文件中读取配置信息：" + myKey);
        System.out.println("从配置文件中读取配置信息：" + myKey2);
        System.out.println("从配置文件中读取配置信息：" + myKey3);
    }
}
